<template>
  <div id="app">
    <table>
      <th>{{ msg }}</th>
      <tr>
        {{
          price
        }}
      </tr>
      <tr>
        请输入你要购买的斤数
        <input type="text" v-model="quantity" />
      </tr>
      <tr>
        <button @click="btn">结账买单-</button>
      </tr>
      <tr>
        结账单:　 总价：{{
          total
        }}　折后价：{{
          cut
        }}
        　省了:
        {{
          saved
        }}
        ￥元
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: "欢迎光临 vue开发的收银系统-水果店",
      price: "苹果 10 ￥/ 斤，折扣<8 折>",
      quantity: "0",
      total: "0",
      cut: "0",
      saved: "0",
    };
  },
  methods: {
    btn() {
      // quantity = input.val();
      this.total = this.quantity * 10;
      this.cut = this.total * 0.8;
      this.saved = this.total - this.cut;
    },
  },
};
</script>

<style>
#app {
  width: 800px;
  height: 500px;
  margin: 0 auto;
  border: 1px solid #000;
}
table {
  width: 100%;
}

th,
tr {
  height: 100px;
  text-align: center;
  line-height: 100px;
}
th {
  border-bottom: 1px solid #000;
}
</style>